package edu.stanford.bmir.protege.web.client.ui.ontology.stkos.merger.common;

import com.gwtext.client.widgets.tree.TreeNode;

import edu.stanford.bmir.protege.web.client.project.Project;
import edu.stanford.bmir.protege.web.client.rpc.data.EntityData;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.common.treepanel.StkosIndividualTreePanel;
import edu.stanford.bmir.protege.web.shared.entity.OWLNamedIndividualData;

public class StkosMergerIndividualTreePanel extends StkosIndividualTreePanel {

	private Project accordingProject;

	public StkosMergerIndividualTreePanel(Project project, EntityData ownerCls) {
		this(project, null, ownerCls);
	}

	public StkosMergerIndividualTreePanel(Project project,
			Project accordingProject, EntityData ownerCls) {
		super(project, ownerCls);
		this.accordingProject = accordingProject;
	}

	public void setAccordingProject(Project accordingProject) {
		this.accordingProject = accordingProject;
		onRefresh();
	}

	@Override
	protected TreeNode createTreeNode(OWLNamedIndividualData owlEntityData) {
		TreeNode node = super.createTreeNode(owlEntityData);
		if (node == null) {
			return null;
		}
		EntityData entityData = toEntityData(owlEntityData);
		addAnnotationMergedFlagNodeMark(node, entityData);
		if (accordingProject != null) {
			addAnnotationMappingNoNodeMark(node, entityData, accordingProject
					.getProjectId().getId());
		}
		return node;
	}
}
